﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace HeritageAcademy.Library.Controls
{
	/// <summary>
	/// Interaction logic for CourseTest.xaml
	/// </summary>
	public partial class CourseTest : UserControl
	{
		public CourseTest()
		{
			this.InitializeComponent();
		}

        public string Question
        {
            get { return tbQuestion.Text; }
            set { tbQuestion.Text = value; }
        }

        public StackPanel Answers
        {
            get { return spAnswers; }
            set { spAnswers = value; }
        }

        public string PicturePath
        {
            //get { return imgPicture.Source;  }
            set 
            {
                if (File.Exists(value))
                    imgPicture.Source = new BitmapImage(new Uri(value, UriKind.RelativeOrAbsolute));
            }
        }

        public List<string> GetAnswerIdList()
        {
            List<string> answerId = new List<string>();
            int i = 0;
            foreach (var answer in spAnswers.Children)
            {
                ++i;
                if (answer.GetType() == typeof(RadioButton))
                {
                    if (((RadioButton)answer).IsChecked == true)
	                {
                        answerId.Add(i.ToString());
	                }
                }
                else if (answer.GetType() == typeof(CheckBox))
                {
                    if (((CheckBox)answer).IsChecked == true)
                    {
                        answerId.Add(i.ToString());
                    }
                }
            }
            return answerId;
        }
	}
}